import os, sys
from pathlib import Path

current_dir = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(current_dir))

from dotenv import load_dotenv

from dataclasses import dataclass
from typing import Optional

load_dotenv(current_dir / "insight_agent" / ".env", override=True)

# load_dotenv()

env = "dev" #如果合并后运行，请选择: env = "prd"

# print(os.getenv("DATABASE_URL"))

@dataclass(frozen=True)
class DatabaseConfig:
    db_host: str = "localhost"
    db_port: int = 3306
    db_name: str = 'user_insight'
    db_user: str = 'root'
    db_password: str = ''

@dataclass(frozen=True)
class LLMConfig:
    BASE_URL: str
    ALIYUN_API_KEY: str
    MODEL: Optional[str] = 'qwen-max'


DB_CONFIG = DatabaseConfig(
    db_host=os.getenv("HOST"),
    db_port=int(os.getenv("PORT")),
    db_name=os.getenv("DB_NAME"),
    db_user=os.getenv("USER"),
    db_password=os.getenv("MYSQL_PW")
)

if env == "dev":
    DS_CONFIG= LLMConfig(
        BASE_URL=os.getenv("DASHSCOPE_API_BASE"),
        ALIYUN_API_KEY=os.getenv("DASHSCOPE_API_KEY"),
        MODEL='deepseek-v3'
    )
    QWEN_CONFIG = LLMConfig(
        BASE_URL=os.getenv("DASHSCOPE_API_BASE"),
        ALIYUN_API_KEY=os.getenv("DASHSCOPE_API_KEY"),
        MODEL='qwen-max'
    )
elif env == "prd":
    DS_CONFIG= LLMConfig(
        BASE_URL=os.getenv("DASHSCOPE_API_BASE"),
        ALIYUN_API_KEY=os.getenv("DASHSCOPE_API_KEY"),
        MODEL='deepseek-chat'
    )
    QWEN_CONFIG = LLMConfig(
        BASE_URL=os.getenv("DASHSCOPE_API_BASE"),
        ALIYUN_API_KEY=os.getenv("DASHSCOPE_API_KEY"),
        MODEL='qwen-max'
    )



# print(DB_CONFIG)
# print(DS_CONFIG)